using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Main : MonoBehaviour
{
    AudioSource BGM;
    Button startButton;
    Button quitButton;
    void Awake()
    {
        BGM = GetComponent<AudioSource>();
        startButton = transform.GetChild(1).GetComponent<Button>();
        startButton.onClick.AddListener(StartGame);
        quitButton = transform.GetChild(2).GetComponent<Button>();
        quitButton.onClick.AddListener(QuitGame);
        GameObject.Find("Score").GetComponent<Text>().text = $"{GameManager.Instance.Score}";
        GameManager.Instance.isSound = true;
        GameManager.Instance.isMusic = true;
    }

    public void StartGame()
    {
        BGM.Stop();
        SceneManager.LoadScene("gameScene");
        // Debug.Log("开始游戏");
    }

    public void QuitGame()
    {
#if UNITY_EDITOR
        UnityEditor.EditorApplication.isPlaying = false; // 退出播放模式
#else
            Application.Quit();
#endif
        // Debug.Log("退出游戏");
    }
}
